#include "orthographic.h"

// OrthographicCamera Definitions
OrthoCamera::OrthoCamera(const Transform &cam2world,
        const float screenWindow[4], float sopen, float sclose,
        float lensr, float focald, Film *f)
    : ProjectiveCamera(cam2world, Orthographic(0., 1.), screenWindow,
                       sopen, sclose, lensr, focald, f) {
    // Compute differential changes in origin for ortho camera rays
    dxCamera = RasterToCamera(Vector(1, 0, 0));
    dyCamera = RasterToCamera(Vector(0, 1, 0));
}


float OrthoCamera::GenerateRay(const CameraSample &sample, Ray *ray) const {
    // Generate raster and camera samples
    Point Pras(sample.imageX, sample.imageY, 0);
    Point Pcamera;
    RasterToCamera(Pras, &Pcamera);
    *ray = Ray(Pcamera, Vector(0,0,1), 0.f, INFINITY);
    // Modify ray for depth of field
//    if (lensRadius > 0.) {
//        // Sample point on lens
//        float lensU, lensV;
//        ConcentricSampleDisk(sample.lensU, sample.lensV, &lensU, &lensV);
//        lensU *= lensRadius;
//        lensV *= lensRadius;

//        // Compute point on plane of focus
//        float ft = focalDistance / ray->d.z;
//        Point Pfocus = (*ray)(ft);

//        // Update ray for effect of lens
//        ray->o = Point(lensU, lensV, 0.f);
//        ray->d = Normalize(Pfocus - ray->o);
//    }
    ray->time = Lerp(sample.time, shutterOpen, shutterClose);
    CameraToWorld(*ray, ray);
    return 1.f;
}

